function projectStruct = gui_copyProject(toProjectStruct, fromProject, pref)
try
    p = fromProject;
    ps = toProjectStruct;

    if(isfield(p,'frame_rate'))
        ps.frameRate = p.frame_rate;
    end

    ps.soundBoundsArr = p.sound_bounds_arr(1:(end-1),1:2);

    ps.firstFrameIndex = p.frame_in;
    ps.lastFrameIndex = p.frame_out;

    % Directories presets.
    if(isempty(p.scratch_directory))
        ps.scratchDir1 = pref.scratch_directory;
    else
        ps.scratchDir1 = p.scratch_directory;
    end

    if(isempty(p.scratch_directory2))
        ps.scratchDir2 = pref.scratch_directory2;
    else
        ps.scratchDir2 = p.scratch_directory2;
    end

    if(isempty(p.output_directory))
        ps.outputDir = ps.scratchDir1;
    else
        ps.outputDir = p.output_directory;
    end

    % Sound extraction presets.
    ps.framesPerBatch = p.frames_per_batch_rough;
    ps.readingAttempts = p.read_write_attempts_rough;
    ps.signalsPerMask = p.signals_per_mask; 
    ps.framesForOverlapGuess = p.frames_for_overlap_guess;
    ps.rowsToIgnore = p.max_rows_to_ignore;

    if(p.max_rows_to_ignore_is_percent)
        ps.rowsToIgnoreUnits.currChoiceInd = 2;
    else
        ps.rowsToIgnoreUnits.currChoiceInd = 1;
    end

    ps.initialSearchRadius = p.initial_search_radius;
    ps.localSearchRadius = p.local_min_neighborhood_radius;
    ps.overlapThreshold = p.overlap_threshold;
    ps.isMovingAverageOn = ~p.do_poly_fit;
    ps.sweeps = p.moving_average_smoothing_passes;
    ps.span = p.moving_average_span;
    ps.isPolynomialOn = p.do_poly_fit;
    ps.isDegree1On = p.poly_fit_degree(1);
    ps.isDegree2On = p.poly_fit_degree(2);
    ps.isDegree3On = p.poly_fit_degree(3);
    ps.isDegree4On = p.poly_fit_degree(4);

    % Sound smoothing presets.
    ps.isSoundSmoothingOn = p.do_smooth_sound;
    ps.smoothingSpan = p.smooth_sound_moving_average_span;

    % Log keeping presets.
    ps.isLogKeepingOn = p.do_log_file;

    % Visual diagnostics presets.
    ps.isVisualDiagnosticsOn = p.do_visualization;

    % Export presets.
    %ps.exportOptions.choicesCellArr
    %ps.exportOptions.currChoiceInd
    %ps.isOpenInExternalPlayerOn

    % Audio presets.
    %ps.maxAmplitude
    %ps.bitDepth.choicesCellArr
    %ps.bitDepth.currChoiceInd
    %ps.samplingRate.choicesCellArr
    ps.samplingRate.currChoiceInd = 1; % native

    % Video presets.
    %ps.frameOffset.choicesCellArr
    %ps.frameOffset.currChoiceInd
    %ps.isOriginalVideoOn
    %ps.isVideoFromImagesOn
    %ps.isImagesOn
    %ps.isPreserveAspectRatioOn
    %ps.isMp4QualityOn
    %ps.mp4QualityPerc
    %ps.isUncompressedOn
    %ps.exportWidth
    %ps.exportHeight

    projectStruct = setUpProjectDirectories(ps);
    
catch exception
    projectStruct = [];
    gui_exception(exception);
    e = exception
end
